/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * UserFrame.java
 *
 * Created on 2011-8-22, 20:07:21
 */
package scau.jump.securitytrace.popupwindow;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JDialog;
import javax.swing.JFrame;

import scau.jump.securitytrace.client.ManagerClient;

/**
 *
 * @author Administrator
 */
public class UserWindow extends JDialog {

	private static final long serialVersionUID = 8607288771846469846L;
	private ManagerClient managerClient;
	/** Creates new form UserFrame */
    public UserWindow(JFrame frame, boolean flag) {
    	super(frame,flag);
    	this.managerClient = (ManagerClient) frame;
        initComponents();
        int parentWidth = (int)managerClient.getLocation().getX();
        int parentHight = (int)managerClient.getLocation().getY();
        int width = this.getWidth();
        int hight = this.getHeight();
        this.setLocation(parentWidth+width/2, parentHight+hight/2);
        init();
    }

    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        mainPanel = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        userAccountTextField = new javax.swing.JTextField();
        userPasswordTextField = new javax.swing.JTextField();
        userSubmitButton = new javax.swing.JButton();
        userResetButton = new javax.swing.JButton();
        userAddressComboBox = new javax.swing.JComboBox();
        userRoleComboBox = new javax.swing.JComboBox();

       // setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        jLabel1.setText("用户帐号：");
        jLabel2.setText("用户密码：");
        jLabel3.setText("登 记 点：");
        jLabel4.setText("角色分配：");
        jLabel5.setFont(new java.awt.Font("宋体", 1, 18)); // NOI18N
        jLabel5.setText(" 用  户  信  息");
        userSubmitButton.setText("确定");
        userResetButton.setText("取消");
        userAddressComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2"}));
        userRoleComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2"}));

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addGap(116, 116, 116)
                        .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(mainPanelLayout.createSequentialGroup()
                        .addGap(61, 61, 61)
                        .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(userRoleComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(userAccountTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 235, Short.MAX_VALUE)
                            .addComponent(userPasswordTextField)
                            .addGroup(mainPanelLayout.createSequentialGroup()
                                .addComponent(userSubmitButton)
                                .addGap(78, 78, 78)
                                .addComponent(userResetButton))
                            .addComponent(userAddressComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap(78, Short.MAX_VALUE))
        );

        mainPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {userAccountTextField, userAddressComboBox, userPasswordTextField, userRoleComboBox});

        mainPanelLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2, jLabel3, jLabel4});

        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(userAccountTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(userPasswordTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(10, 10, 10)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(userAddressComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(userRoleComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(userResetButton)
                    .addComponent(userSubmitButton))
                .addContainerGap(18, Short.MAX_VALUE))
        );

        mainPanelLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jLabel1, jLabel2, jLabel3, jLabel4, userAccountTextField, userAddressComboBox, userPasswordTextField, userRoleComboBox});

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(mainPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    void init() {
    	userResetButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				UserWindow userWindow = UserWindow.this;
				userWindow.dispose();
			}
		});
    }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JButton userResetButton;
    
    private javax.swing.JTextField userAccountTextField;
    private javax.swing.JComboBox userAddressComboBox;
    private javax.swing.JTextField userPasswordTextField;
    private javax.swing.JComboBox userRoleComboBox;
    private javax.swing.JButton userSubmitButton;
    // End of variables declaration//GEN-END:variables
    /**
     * 以下为get/set 方法
     */
	public void setAddUserButtonListener(ActionListener actionListener) {
		this.userSubmitButton.addActionListener(actionListener);
	}
	public void setUserAddressComboBox(javax.swing.JComboBox userAddressComboBox) {
		this.userAddressComboBox = userAddressComboBox;
	}
	public void setUserRoleComboBox(javax.swing.JComboBox userRoleComboBox) {
		this.userRoleComboBox = userRoleComboBox;
	}
	public ManagerClient getManagerClient() {
		return managerClient;
	}
	public javax.swing.JTextField getUserAccountTextField() {
		return userAccountTextField;
	}
	public javax.swing.JComboBox getUserAddressComboBox() {
		return userAddressComboBox;
	}
	public javax.swing.JTextField getUserPasswordTextField() {
		return userPasswordTextField;
	}
	public javax.swing.JComboBox getUserRoleComboBox() {
		return userRoleComboBox;
	}
	public javax.swing.JButton getUserSubmitButton() {
		return userSubmitButton;
	}
}
